package top.zsyle.movie.fallback;

import com.baomidou.mybatisplus.mapper.Wrapper;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import top.zsyle.movie.domain.MovieTicket;
import top.zsyle.movie.domain.UserMovie;
import top.zsyle.movie.dto.GetMiddleDto;
import top.zsyle.movie.exception.GlobalExceptionEnum;
import top.zsyle.movie.feign.MovieService;
import top.zsyle.movie.result.JsonResult;

@Component
public class MovieServiceFallbackFactory implements FallbackFactory<MovieService> {


    @Override
    public MovieService create(Throwable throwable) {
        return new MovieService() {
            @Override
            public JsonResult list() {
                return JsonResult.error(GlobalExceptionEnum.MOVIE_GET_LIST_EXCEPTION.getMessage(),GlobalExceptionEnum.MOVIE_GET_LIST_EXCEPTION.getCode());
            }

            @Override
            public JsonResult listNotOverTime(Wrapper<MovieTicket> wrapper) {
                return JsonResult.error(GlobalExceptionEnum.ERROR.getMessage(),GlobalExceptionEnum.ERROR.getCode());
            }

            @Override
            public JsonResult get(Long id) {
                return JsonResult.error(GlobalExceptionEnum.MOVIE_GET_BY_ID_EXCEPTION.getMessage(),GlobalExceptionEnum.MOVIE_GET_BY_ID_EXCEPTION.getCode());
            }

            @Override
            public JsonResult saveOrUpdateMiddle(UserMovie userMovie) {
                return JsonResult.error(GlobalExceptionEnum.MOVIE_ADD_OR_UPDATE_MIDDLE_EXCEPTION.getMessage(),GlobalExceptionEnum.MOVIE_ADD_OR_UPDATE_MIDDLE_EXCEPTION.getCode());
            }


            @Override
            public JsonResult saveOrUpdate(MovieTicket movieTicket) {
                return JsonResult.error(GlobalExceptionEnum.MOVIE_SAVE_OR_UPDATE_EXCEPTION.getMessage(),GlobalExceptionEnum.MOVIE_SAVE_OR_UPDATE_EXCEPTION.getCode());
            }

            @Override
            public JsonResult getUserMovie(Long id) {
                return JsonResult.error(GlobalExceptionEnum.ERROR.getMessage(),GlobalExceptionEnum.ERROR.getCode());
            }

            @Override
            public JsonResult getMiddleByUserIdAndMovieId(GetMiddleDto dto) {
                return JsonResult.error(GlobalExceptionEnum.ERROR.getMessage(),GlobalExceptionEnum.ERROR.getCode());
            }
        };
    }
}
